package com.burgstaller.aGTD.utils;

import android.content.Context;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;

import com.burgstaller.controls.IconifiedTextView;
import com.burgstaller.provider.AGtd;

public class IconedCursorAdapter extends CursorAdapter {
	private Drawable m_normalIcon;
	private int m_titleColumnIndex;
	
	public IconedCursorAdapter(Cursor c, Context context, 
			int titleColumnIndex, 
			Drawable icon) {
		super(c, context);
		m_titleColumnIndex = titleColumnIndex;
		m_normalIcon = icon;
	}
	
	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		IconifiedTextView iconView = (IconifiedTextView) view;
		iconView.setIcon(m_normalIcon);
		iconView.setText(cursor.getString(m_titleColumnIndex));
		Log.d(AGtd.LOG_TAG, "have icon: " + iconView.getIcon());
	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup viewgroup) {
        return new IconifiedTextView(mContext);
	}

}
